home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cdropin1.arc
/
TESTFILE.C
< prev
next >
Wrap
Text File
|
1985-10-02
|
2KB
|
55 lines
/* testfile.c - file copy benchmark for Blaise Ctools2 */
#include "stdio.h"
#include "filehand.h"
/* data type for 8088 address*/
typedef struct { int r ; int s ; } ADS ;
char buffer[16384] ; /* I/O area */
main(argc,argv)
int argc ;
char *argv[] ;
{
int in ,
out ;
long n ;
int ercode , ercode2 ;
unsigned nr , nw , c ;
ADS bufads ;
unsigned cs,ss,ds,es ;
utsreg(&cs,&ss,&ds,&es) ; /* build segmented address for*/
bufads.r = (int) & buffer ; /* I/O area */
bufads.s = (int) ds ;
if( argc < 3 )
{ printf("\n no file names \n");
exit(0);
}
printf("\n bytes to read \n");
scanf("%d",&nr);
ercode = flopen(argv[1],&in,RDONLY); /* open files */
ercode2 = flcreate(argv[2],&out,WRTONLY);
if( (ercode != 0) || (ercode2 != 0) )
{ printf("can't open a file %d %d",ercode,ercode2);
exit(0) ;
}
n=0;
ercode = flread(in,& bufads,nr,&c) ; /* 1st read */
while( (ercode == 0) && (c > 0) ) /* repeat until EOF */
{ n=n+c ;
ercode2 = flwrite(out,& bufads,c,&nw); /* write */
if( (ercode2 != 0) || (nw != c) )
{ printf(" write error-code=%d nw=%u\n",ercode2,nw);
break ;
}
ercode = flread(in,& bufads,nr,&c) ; /* read next */
} ;
printf("\n thru - %ld chars\n",n);
printf(" ercode = %d \n",ercode) ;
ercode = flclose(in);
ercode2 = flclose(out);
printf("\n close error codes - %d %d\n",ercode,ercode2);
}